import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from "path"
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  server:{
    host:'localhost',
    port:5000,
    open:true,   // 自动打开浏览器
    proxy:{
      "/user-api":{
        target:"http://localhost:8888",
        changeOrigin:true,
        rewrite:url=>url.replace(/^\/user-api/,"/user-api/api/v1")
      },
      "/member-api":{
        target:"http://localhost:8888",
        changeOrigin:true,
        rewrite:url=>url.replace(/^\/member-api/,"/member-api/api/v1")
      },
      "/order-api":{
        target:"http://localhost:8888",
        changeOrigin:true,
        rewrite:url=>url.replace(/^\/order-api/,"/order-api/api/v1")
    },
      "/address-api":{
        target:"http://localhost:8888",
        changeOrigin:true,
        rewrite:url=>url.replace(/^\/address-api/,"/address-api/api/v1")
      },
      "/api":{
        target:"http://localhost:8888",
        changeOrigin:true,
        rewrite:url=>url.replace(/^\/api/,"/good-api/api/v1")
      }
  }
  },
  //配置别名
  resolve:{
    alias:[
      {
        find:"@",
        replacement:resolve(__dirname,"src")
      }
    ]
  }
})


